import request from "@/utils/request"

const ROLE_MENU_BASE_URL = "/api/object/com.siline.chimes/ChimesRolesMenus"

class RoleMenuAPI {
  /**
   * 获取角色菜单数据
   */
  static query(data: QueryCondition = {}) {
    return request<any, ResponseData<RoleMenuVO[]>>({
      url: `${ROLE_MENU_BASE_URL}/query`,
      method: "post",
      data,
    })
  }

  /** 添加角色菜单 */
  static add(data: RoleMenuForm) {
    return request<any, ResponseData<RoleMenuForm>>({
      url: `${ROLE_MENU_BASE_URL}/insert`,
      method: "post",
      data: data,
    })
  }

  /**
   * 更新角色
   *
   * @param data 角色表单数据
   */
  static update(data: RoleMenuForm) {
    return request<any, ResponseData<RoleMenuForm>>({
      url: `${ROLE_MENU_BASE_URL}/update`,
      method: "post",
      data: data,
    })
  }

  /**
   * 根据条件批量删除角色
   *
   * @param data
   */
  static deleteByCondition(data: QueryCondition) {
    return request({
      url: `${ROLE_MENU_BASE_URL}/delete_by`,
      method: "post",
      data: data,
    })
  }

  /** 批量添加角色菜单 */
  static saveBatch(data: RoleMenuForm[]) {
    return request<any, ResponseData<RoleMenuForm>>({
      url: `${ROLE_MENU_BASE_URL}/save_batch`,
      method: "post",
      data: data,
    })
  }
}
export default RoleMenuAPI

export interface RoleMenuVO {
  /** 角色ID */
  role_id?: number
  /** 菜单ID */
  menu_id?: number
}

export interface RoleMenuForm {
  /** 角色ID */
  role_id?: number
  /** 菜单ID */
  menu_id?: number
}
